package com.zjcloud.motr.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zjcloud.motr.vo.ZjyStaffTimingMonthVO;
import com.zjcloud.motr.vo.ZjyStaffTimingVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.motr.domain.ZjyStaffTiming;
import com.zjcloud.motr.service.IZjyStaffTimingService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 人员记时Controller
 * 
 * @author wxl
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/motr/timing")
public class ZjyStaffTimingController extends BaseController
{
    @Autowired
    private IZjyStaffTimingService zjyStaffTimingService;

    /**
     * 查询人员记时列表
     */
    @PreAuthorize("@ss.hasPermi('motr:timing:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZjyStaffTiming zjyStaffTiming)
    {
        startPage();
//        List<ZjyStaffTiming> list = zjyStaffTimingService.selectZjyStaffTimingList(zjyStaffTiming);
        List<ZjyStaffTimingVO> list = zjyStaffTimingService.selectZjyStaffTimingListVO(zjyStaffTiming);
        return getDataTable(list);
    }

    /**
     * 查询人员记时列表
     */
    @GetMapping("/listmonth/{month}")
    public TableDataInfo listlistmonth(@PathVariable("month")Date month)
    {
        startPage();
        List<ZjyStaffTimingMonthVO> list = zjyStaffTimingService.selectZjyStaffTimingMonthListVO(month);
        return getDataTable(list);
    }

    /**
     * 导出人员记时列表
     */
    @PreAuthorize("@ss.hasPermi('motr:timing:export')")
    @Log(title = "人员记时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjyStaffTiming zjyStaffTiming)
    {
        List<ZjyStaffTiming> list = zjyStaffTimingService.selectZjyStaffTimingList(zjyStaffTiming);
        ExcelUtil<ZjyStaffTiming> util = new ExcelUtil<ZjyStaffTiming>(ZjyStaffTiming.class);
        util.exportExcel(response, list, "人员记时数据");
    }

    /**
     * 获取人员记时详细信息
     */
    @PreAuthorize("@ss.hasPermi('motr:timing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zjyStaffTimingService.selectZjyStaffTimingById(id));
    }

    /**
     * 新增人员记时
     */
    @PreAuthorize("@ss.hasPermi('motr:timing:add')")
    @Log(title = "人员记时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZjyStaffTiming zjyStaffTiming)
    {
        return toAjax(zjyStaffTimingService.insertZjyStaffTiming(zjyStaffTiming));
    }

    /**
     * 修改人员记时
     */
    @PreAuthorize("@ss.hasPermi('motr:timing:edit')")
    @Log(title = "人员记时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZjyStaffTiming zjyStaffTiming)
    {
        return toAjax(zjyStaffTimingService.updateZjyStaffTiming(zjyStaffTiming));
    }

    /**
     * 删除人员记时
     */
    @PreAuthorize("@ss.hasPermi('motr:timing:remove')")
    @Log(title = "人员记时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zjyStaffTimingService.deleteZjyStaffTimingByIds(ids));
    }
}
